using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TidhiGanitam.DataModel;
using TidhiGanitam;
using System.Xml;
using System.IO;

namespace TidhiGanitam
{
    public partial class RavichandraValues : Form
    {
        public RavichandraValues()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime ugadi = dateTimePicker1.Value;
            Rasi RRK = new Rasi(Convert.ToDouble(RK.Text.ToString()));
            Rasi RRM = new Rasi(Convert.ToDouble(RM.Text.ToString()));
            Rasi RCK = new Rasi(Convert.ToDouble(CK.Text.ToString()));
            Rasi RCM = new Rasi(Convert.ToDouble(CM.Text.ToString()));

            StringBuilder sbRavi = new StringBuilder();
            for (int i = 0; i < 370; i++)
            {
                sbRavi.AppendFormat("{2}){3}:: {0}\t{1} --- {4}\t{5}{6}", RRK.ToString(), RRM.ToString(),
                    i.ToString(), ugadi.ToString("dd-MMM-yy"),
                    RCK.ToString(), RCM.ToString(), Environment.NewLine);
                RRK = new Rasi(RRK + Constants.RaviDinaGati);
                RRM = new Rasi(RRM + Constants.RaviDinaGati);
                RCK = new Rasi(RCK + Constants.ChandraKendraDinaGati);
                RCM = new Rasi(RCM + Constants.ChandraDinaGati);
               ugadi =  ugadi.AddDays(1);
            }
            string DirPath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\panchanzyamu";
            if (!Directory.Exists(DirPath))
            {
                Directory.CreateDirectory(DirPath);
            }
            string FileName = DirPath + "\\Ravi Values" +  ugadi.Year.ToString() +".txt";
            //string DataDirectory = "Ravi.txt";
            using (TextWriter HistoryWriter = new StreamWriter(FileName, false))
            {
                HistoryWriter.WriteLine(sbRavi.ToString());
            }

        }
        public void WriteRaviChandraValuestoFile()
        {
            //StringBuilder sbRavi = new StringBuilder();
            //for (int i = 0; i < 370; i++)
            //{
            //    RaviRoutineItem RviRoutine = (RaviRoutineItem)ravi.DailyCalculations[i];
            //    ChandraRoutineItem ChndrRoutine = (ChandraRoutineItem)chandrudu.DailyCalculations[i];
            //    sbRavi.AppendFormat("{2}-{3}:: {0}\t{1} --- {4}\t{5}{6}", RviRoutine.MadyamaRavi.ToString(), RviRoutine.RaviKendram.ToString(),
            //        RviRoutine.Bhagam.ToString(), RviRoutine.Date.ToString("dd-MMM-yy"),
            //        ChndrRoutine.ChandraKendram.ToString(), ChndrRoutine.SpastaChandrudu.ToString(), Environment.NewLine);
            //}
            //string DataDirectory = "Ravi.txt";
            //using (TextWriter HistoryWriter = new StreamWriter(DataDirectory, false))
            //{
            //    HistoryWriter.WriteLine(sbRavi.ToString());
            //}
        }

    }
}